package org.apache.ocean;

import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.ocean.util.OceanConcurrentHashMap;

/**
 *
 * @author jasonr
 */
public class ClusterRegistry {
  public static Logger log = Logger.getLogger(ClusterRegistry.class.getName());
  public static ConcurrentHashMap<String,Object> map = new OceanConcurrentHashMap<String,Object>();
  
  public ClusterRegistry() {
  }
  
  public void stop() {
    for (Object object : map.values()) {
      if (object instanceof Service) {
        Service service = (Service)object;
        try {
          service.stop();
        } catch (Throwable throwable) {
          log.log(Level.SEVERE, "", throwable);
        }
      }
    }
  }
  
  public static void put(String name, Object value) {
    map.put(name, value);
  }
  
  public static Object get(String name) {
    return map.get(name);
  }
}
